package com.liusy.code.templates;

import com.liusy.code.bean.*;

public class ServiceTemplate
{
  protected static String nl;
  public static synchronized ServiceTemplate create(String lineSeparator)
  {
    nl = lineSeparator;
    ServiceTemplate result = new ServiceTemplate();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "package ";
  protected final String TEXT_2 = ";" + NL + "" + NL + "" + NL + "import com.gdtopway.zhaobiao.util.PageContent;" + NL + "import com.gdtopway.zhaobiao.util.PageRequest;" + NL + "import java.util.HashMap;" + NL + "import java.util.Map;" + NL + "import java.util.List;" + NL + "" + NL + "import ";
  protected final String TEXT_3 = ".";
  protected final String TEXT_4 = ";" + NL + "" + NL + "/**" + NL + " * 服务接口类：" + NL + " * " + NL + " * @author " + NL + " * " + NL + " */" + NL + "public interface ";
  protected final String TEXT_5 = " {" + NL + "" + NL + "\tpublic ";
  protected final String TEXT_6 = " get(String id);" + NL + "" + NL + "\tpublic ";
  protected final String TEXT_7 = " update(";
  protected final String TEXT_8 = " ";
  protected final String TEXT_9 = ");" + NL + "" + NL + "\tpublic List<";
  protected final String TEXT_10 = "> get";
  protected final String TEXT_11 = "List();" + NL + "" + NL + "\tpublic PageContent find";
  protected final String TEXT_12 = "List(PageRequest pageRequest, Map<String, String> queryParam);" + NL + "" + NL + "\tpublic void delete(String id);" + NL + "\t" + NL + "\tpublic ";
  protected final String TEXT_13 = " save(";
  protected final String TEXT_14 = " ";
  protected final String TEXT_15 = ");" + NL + "}" + NL;
  protected final String TEXT_16 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    
	JavaTemplateArgs args = (JavaTemplateArgs)argument;

    stringBuffer.append(TEXT_1);
    stringBuffer.append(args.getPackageName());
    stringBuffer.append(TEXT_2);
    stringBuffer.append(args.getPackageNameInfo().getEntityPackageName());
    stringBuffer.append(TEXT_3);
    stringBuffer.append(args.getClassNameInfo().getEntityClassName());
    stringBuffer.append(TEXT_4);
    stringBuffer.append(args.getClassName());
    stringBuffer.append(TEXT_5);
    stringBuffer.append(args.getClassNameInfo().getEntityClassName());
    stringBuffer.append(TEXT_6);
    stringBuffer.append(args.getClassNameInfo().getEntityClassName());
    stringBuffer.append(TEXT_7);
    stringBuffer.append(args.getClassNameInfo().getEntityClassName());
    stringBuffer.append(TEXT_8);
    stringBuffer.append(args.getClassNameInfo().getEntityObjectName());
    stringBuffer.append(TEXT_9);
    stringBuffer.append(args.getClassNameInfo().getEntityClassName());
    stringBuffer.append(TEXT_10);
    stringBuffer.append(args.getClassNameInfo().getEntityClassName());
    stringBuffer.append(TEXT_11);
    stringBuffer.append(args.getClassNameInfo().getEntityClassName());
    stringBuffer.append(TEXT_12);
    stringBuffer.append(args.getClassNameInfo().getEntityClassName());
    stringBuffer.append(TEXT_13);
    stringBuffer.append(args.getClassNameInfo().getEntityClassName());
    stringBuffer.append(TEXT_14);
    stringBuffer.append(args.getClassNameInfo().getEntityObjectName());
    stringBuffer.append(TEXT_15);
    stringBuffer.append(TEXT_16);
    return stringBuffer.toString();
  }
}
